﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DTO;
using BUS;

public partial class admin_ContactInformation : System.Web.UI.Page
{
    protected string shortname;
    protected string webname;
    protected string slogan;
    protected string copyright;
    protected string powered;
    protected string designed;
    protected string website;
    protected string address;
    protected string phone;
    protected string email;
    ContactInformationBUS contactInfoBUS = new ContactInformationBUS();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["adminName"] == null)
            Response.Redirect("login.aspx?turn=contactinformation.aspx");
        if (!IsPostBack)
        {
            LoadValues();
        }
    }

    protected void btnChange_Click(object sender, EventArgs e)
    {
        ContactInformationDTO ciDTO = new ContactInformationDTO();
        ciDTO.Address = Request.Form["txtAddress"];
        ciDTO.CompanyName = Request.Form["txtName"];
        ciDTO.Copyright = Request.Form["txtCopyRight"];
        ciDTO.Designed = Request.Form["txtDesigned"];
        ciDTO.Email = Request.Form["txtEmail"];
        ciDTO.Phone = Request.Form["txtPhone"];
        ciDTO.Powered = Request.Form["txtPowered"];
        ciDTO.ShortName = Request.Form["txtShortName"];
        ciDTO.Slogan = Request.Form["txtSlogan"];
        ciDTO.Website = Request.Form["txtWebsite"];
        contactInfoBUS.UpdateContactInformation(ciDTO);
        LoadValues();
    }

    protected void btnReset_Click(object sender, EventArgs e)
    {
        LoadValues();
    }

    protected void LoadValues()
    {
        ContactInformationDTO contactInfoList = contactInfoBUS.GetContactInformation();
        webname = contactInfoList.CompanyName;
        slogan = contactInfoList.Slogan;
        shortname = contactInfoList.ShortName;
        copyright = contactInfoList.Copyright;
        powered = contactInfoList.Powered;
        designed = contactInfoList.Designed;
        website = contactInfoList.Website;
        address = contactInfoList.Address;
        phone = contactInfoList.Phone;
        email = contactInfoList.Email;
    }
}
